package cn.tedu.controller;

import cn.tedu.pojo.car;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhuzhuking
 */
@RestController
@RequestMapping("car")
public class CarController {
    @RequestMapping("get")
    public Object get(car c) {
       return  c;
    }
    /**解析restful风格的参数,简化了get方法传参的写法*/
    @RequestMapping("get2/{id}/{name}")
    public Object get2(@PathVariable Integer id, @PathVariable String name) {
        //@PathVariable --获取{}中间变量的值
        return id+name;
    }
    @RequestMapping("get3/{id}/{name}/{color}/{price}")
    public String get3(@PathVariable Integer id,
                       @PathVariable String name,
                       @PathVariable String color,
                       @PathVariable Double price) {
        return id+","+name+","+color+","+price;
    }
}
